The 'gpsd' offers the possibility to call the script '/etc/gpsd/device-hook'
when a GPS source was added or removed via gpsdctl.
In addition to the '/etc/gpsd/device-hook' call an event is now triggered
too after the 'gpsd' has started. This allows scripts to configurre 'gpsd'
receivers.
The following events are available for '/etc/hotplug.d/gpsd' scripts:
* ACTIVATE via '/etc/gpsd/device-hook'
* DEACTIVATE via '/etc/gpsd/device-hook'
* STARTED via '/etc/init.d/gpsd'
Signed-off-by: Florian Eckert <[email protected]>
PKG_NAME:=gpsd
PKG_VERSION:=3.25
-PKG_RELEASE:=3
+PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@SAVANNAH/$(PKG_NAME)
$(INSTALL_BIN) ./files/gpsd.init $(1)/etc/init.d/gpsd
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/gpsd $(1)/usr/sbin/
+
+ $(INSTALL_DIR) $(1)/etc/gpsd
+ $(INSTALL_BIN) ./files/etc/gpsd/device-hook $(1)/etc/gpsd/
endef
define Package/gpsd-clients/install
--- /dev/null
+#!/bin/sh
+
+main() {
+ local device="$1"
+ local action="$2"
+
+ case "$action" in
+ "ACTIVATE")
+ env -i ACTION="$action" DEVICE="$device" \
+ /sbin/hotplug-call gpsd
+ ;;
+ "DEACTIVATE")
+ env -i ACTION="$action" DEVICE="$device" \
+ /sbin/hotplug-call gpsd
+ ;;
+ esac
+}
+
+main "$@"
--- /dev/null
+#!/bin/sh
+
+gps_log() {
+ local level="$1"; shift
+
+ [ "$level" = "debug" ] && return
+ logger -p "daemon.${level}" -t "gpsd(debug)[$$]" "hotplug: $*"
+}
+
+main() {
+ gps_log info "$(env)"
+}
+
+main "$@"
procd_add_reload_trigger "$NAME"
procd_add_validation validate_section_gpsd
}
+
+service_started() {
+ local enabled
+
+ enabled="$(uci_get gpsd core enabled 0)"
+ [ "$enabled" = "0" ] && return
+
+ env -i ACTION="STARTED" /sbin/hotplug-call gpsd
+}